# Maintainer: Martell Malone <martellmalone@gmail.com>

_realname=winstorecompat
pkgbase=mingw-w64-${_realname}-git
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
pkgver=11.0.0.r124.ge89de847d
pkgrel=1
_commit='e89de847dd3e05bb8e46344378ce3e124f4e7d1c'
pkgdesc="MinGW-w64 winRT compat library"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://mingw-w64.sourceforge.io/"
license=('custom')
groups=("${MINGW_PACKAGE_PREFIX}-toolchain")
makedepends=("git"
             "${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-binutils"
             "${MINGW_PACKAGE_PREFIX}-crt"
             "${MINGW_PACKAGE_PREFIX}-headers"
             "${MINGW_PACKAGE_PREFIX}-autotools")
options=('!buildflags' '!emptydirs')
source=("mingw-w64"::"git+https://git.code.sf.net/p/mingw-w64/mingw-w64#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd "${srcdir}/mingw-w64"
  git describe --long ${_commit} | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^v//g'
}

build() {
  [[ -d ${srcdir}/build-${MSYSTEM} ]] && rm -rf ${srcdir}/build-${MSYSTEM}
  mkdir -p ${srcdir}/build-${MSYSTEM} && cd ${srcdir}/build-${MSYSTEM}

  ${srcdir}/mingw-w64/mingw-w64-libraries/winstorecompat/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}

  make
}

package() {
  cd ${srcdir}/build-${MSYSTEM}
  make DESTDIR=${pkgdir} install
}
